package com.uzai.console.web.report;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.device.DeviceQuery;
import com.uzai.console.dto.report.RobotDataReportExportResultDto;
import com.uzai.console.dto.report.RobotDataReportQuery;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.device.DeviceService;
import com.uzai.console.service.report.RobotDataReportService;
import com.uzai.console.vo.device.DeviceInfoVo;
import com.uzai.console.vo.exportinfo.ExportAmountVo;
import com.uzai.console.vo.report.RobotDataReportVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 登录日志
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "机器人数据",tags = "数据报表|机器人数据")
@ApiSort(50)
@RestController
public class RobotDataReportController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(RobotDataReportController.class);

    @Autowired
    private DeviceService deviceService;
    @Autowired
    private RobotDataReportService robotDataReportService;


    @ApiOperation(value = "查询机器人下拉列表", notes = "查询机器人下拉列表", response = DeviceInfoVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/report/findDeviceList")
    public Object findDeviceList(@RequestBody DeviceQuery deviceQuery) {
        deviceQuery.setMerId(getLoginInfo().getMerId());
        return deviceService.findDeviceList(deviceQuery);
    }

    @ApiOperation(value = "分页机器人数据报表", notes = "分页机器人数据报表", response = RobotDataReportVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/report/robotDataReport")
    public Object robotDataReport(@RequestBody RobotDataReportQuery robotDataReportQuery){
        //返回机器人数据报表
        return robotDataReportService.robotDataReport(robotDataReportQuery);
    }

    @ApiOperation(value = "机器人数据报表查询结果导出文件前检验接口", notes = "机器人数据报表查询结果导出文件前检验接口", response = ExportAmountVo.class)
    @ApiOperationSupport(order = 4)
    @PostMapping("/report/robotData/getExportAmount")
    public Object getExportAmount(@RequestBody RobotDataReportQuery robotDataReportQuery){
        return robotDataReportService.getExportAmount(robotDataReportQuery);
    }

    @SystemLogType(model = SystemModelEnum.RobotDataReport, type = OperationTypeEnum.EXPORT)
    @ApiOperation(value = "机器人数据报表查询结果导出文件", notes = "机器人数据报表查询结果导出文件")
    @ApiOperationSupport(order = 5)
    @PostMapping("/report/robotData/exportByQeuryResult")
    public Object exportByQeuryResult(@RequestBody RobotDataReportExportResultDto robotDataReportExportResultDto){
        robotDataReportService.exportByQeuryResult(robotDataReportExportResultDto);
        return true;
    }
    
}
